<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商品修改</title>

    <!-- Bootstrap -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
    <link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <!--    引入首页样式-->
    <link href="favicon.ico" rel="shortcut icon" />
    <link href="../../indexCss.css" rel="stylesheet" type="text/css">
    <style>
        body {
            position: relative;
            color: rgba(0, 0, 0, 0.68)
        }

        a {
            color: rgba(0, 0, 0, 0.68);
            cursor: pointer; /*加手图标*/
            text-decoration: none;
        }

        a:hover {
            color: #24407EAD;
        }

        #topdiv > div {
            margin: 60px 0;

        }

    </style>
</head>
<body>
<!--动态背景画布-->
<!--<canvas id="canvas" style="height: 100%;z-index: -111;"></canvas>-->
<myheader></myheader>

<section>
    <div class="container" id="topdiv">
        <div class="row clearfix">
            <div class="col-md-12 " style="padding: 0;position: relative;">
                <!--            <div class="col-md-8 " style="padding: 0">-->
                <div class="col-md-2 ">
                    <mydiv v-bind:cls="cls" v-bind:com="com" v-bind:rcls="rcls" v-bind:rep="rep"></mydiv>
                </div>
                <div class="col-md-4 " style="padding: 3px;">
                        <div class="thumbnail" style="height: 600px;">
                            <img :src="rep1.url" alt="300x200" style="height: 150px"><!--width: 400px;-->
                            <div class="caption">
                                <textarea cols="45" rows="3">{{rep1.title}}</textarea>
                                <textarea cols="45" rows="12">{{rep1.content}}</textarea>
                                <h5>
                                    <b>创建日期:</b>{{rep1.created}}&nbsp;
                                </h5>
                            </div>
                        </div>
                </div>
                <div class="col-md-6" style="padding: 3px;">
                    <form  enctype="multipart/form-data" id="Aform" style="padding: 50px 20px;background-color: rgb(255,255,255);">
                        <div class="form-group">
                            <label>文章标题</label>
                            <textarea cols="70" name="title" rows="3"></textarea>
<!--                            <input type="text" name="title" class="form-control">-->
                        </div>

                        <div class="form-group">
                            <label>文章正文</label>
                            <textarea cols="70" name="content" rows="9"></textarea>
<!--                            <input type="text" name="content" class="form-control">-->
                           </div>
                        <div class="form-group">
                            <input id="exampleInputFile" name="picFile" type="file"/>
                            <p class="help-block">
                                请选择您所要上架的商品图片
                            </p>
                        </div>
                        <div class="item item-input item-select">
                            <label>请选择所属产品类</label>
                            <select  name="clsId">
                                <option value=0>请选择</option>
                                <option :value="c.id" v-for="c in rcls">{{c.name}}</option>
                            </select>
                            <div style="float: right">
                                <button @click="update1()" class="btn btn-info"  type="button">确认修改</button>
                            </div>
                        </div>

                    </form>
                </div>
            </div>

        </div>

    </div>
    </div>


</section>
<!--正文在这里继续-->

<!--<myfooter></myfooter>-->

<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
<!--导入弹窗组件-->
<script src=" https://unpkg.com/sweetalert/dist/sweetalert.min.js "></script>
<!--引入vue和axios-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>


<script>

    let section_v = new Vue({
        el: "body>section",
        data: {
            cls: {}, //类集合
            com: {}, //商品集合
            rep1: {}, //修改单个资讯信息
            id:"",
            rcls: [], //资讯类集合
            rep: [], //资讯集合
        },
        created: function () {
            let id1 = location.search.split("=")[1]
            axios.post("/admin/ReportSelectById?id=" + id1).then(function (response) {
                section_v.rep1 = response.data;
            })
            axios.post("/admin/selectToClass").then(function (response) {
                section_v.cls = response.data;
            })
            axios.post("/admin/selectToCommodity").then(function (response) {
                section_v.com = response.data;
            })
            axios.post("/admin/selectToReportCls").then(function (response) {
                section_v.rcls = response.data;
            })
            axios.post("/admin/selectToReport").then(function (response) {
                section_v.rep = response.data;
            })

        },
        methods: {
            upda1:function (id){
                location.href="/admin/admin/updateCommodity.html?id="+id;
            },
            update1:function (){
                swal("", "您确认修改嘛", "warning", {
                    button: "我就改",
                }).then((value) => {
                    if (value == true) {
                        section_v.id = location.search.split("=")[1]
                        let data = new FormData(document.getElementById("Aform"))
                        axios.post("/admin/reportUpdate?id=" + section_v.id, data).then(function () {
                            swal("", "修改成功咯!", "info").then((value) => {
                                location.reload();
                            })

                        })
                    } else {
                        swal("", "当然还是算了", "info")
                    }
                });
            }

        }

    })


</script>
<!--引入footer-->
<!--<script src="adminjs/footer.js"></script>-->
<!--引入左侧边栏组件-->
<script src="../adminjs/mydiv.js"></script>
<!--引入header-->
<script src="../adminjs/header.js"></script>
<!--引入动态背景js文件-->
<!--<script src="../bgjs2.js"></script>-->
<!--背景线条-->
<script src="../adminjs/bg.js"></script>　
<!--右键出字体-->
<script src="../adminjs/bgfont.js"></script>　
</body>
</html>